﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LiXiangRegistered.aspx.cs" Inherits="PropertyAppraisal.Registered" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8" />
    <title>借款人员基本信息</title>

    <link href="../jquery-easyui-1.3.5/themes/default/easyui.css" rel="stylesheet" />
    <link type="/text/css" href="../jquery-easyui-1.3.5/themes/icon.css" rel="stylesheet" />
    <script type="text/javascript" src="../jquery-easyui-1.3.5/jquery-1.7.2-min.js"></script>
    <script type="text/javascript" src="../jquery-easyui-1.3.5/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../jquery-easyui-1.3.5/easyloader.js"></script>

</head>
<body>
    <%--  <h2>借款人员基本信息</h2>--%>
    <div class="demo-info">
        <div class="demo-tip icon-tip"></div>
        <%--<div>Fill the form and submit it.</div>--%>
    </div>
    <div style="margin: 0;"></div>
    <div class="easyui-panel" fit="true">
        <div style="margin-left: 30px;" id="ff">
            <div>
                <span>借款人员基本信息：</span>    <iframe width="0" height="0" src="../SessionKeeper.aspx"></iframe>    
            </div>
            <div style="padding: 10px 0 10px 100px">
                <table>
                    <tbody id="tbtb">
                        <tr>
                            <td><span>借款人员姓名：</span><input class="easyui-validatebox a" type="text" id="name" data-options="required:true" missingMessage="必填" maxlength="20" /></td>
                            <td><span>身份证号：</span><input class="easyui-validatebox b" type="text" id="idCard" data-options="required:true" missingMessage="必填" maxlength="20" /></td>
                            <td><span>联系电话：</span><input class="easyui-validatebox c" type="text" id="telNumber" data-options="required:true" maxlength="20" missingMessage="必填" /></td>
                            <td><a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add',toggle:true" onclick="add()">添加借款人</a></td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <div>
                <table>
                    <tr>
                        <td>联系人：</td>
                        <td style="padding-left: 50px;">
                            <input class="easyui-validatebox" type="text" id="linkmen" data-options="required:true" style="width: 800px;" missingMessage="必填" placeholder="请输入联系人" maxlength="100" /></td>
                    </tr>
                    <tr>
                        <td>联系电话：</td>
                        <td style="padding-left: 50px;">
                            <input class="easyui-validatebox" type="text" id="linknumber" data-options="required:true" style="width: 800px;" missingMessage="必填" placeholder="请输入联系电话，多个电话请用，隔开" maxlength="200" /></td>
                    </tr>
                    <tr>
                        <td>房屋剩余年限：</td>
                        <td style="padding-left: 50px;">
                            <input class="easyui-validatebox" type="text" id="overyears" data-options="required:true" style="width: 800px;" missingMessage="必填" placeholder="请输入房屋剩余年限" maxlength="20" /></td>
                    </tr>
                    <tr>
                        <td>贷款额度（万元）：</td>
                        <td style="padding-left: 50px;">
                            <input class="easyui-validatebox" type="text" id="Quota" data-options="required:true" style="width: 800px;" missingMessage="必填" placeholder="请输入贷款额度，单位为万元" maxlength="20" /></td>
                    </tr>
                    <tr>
                        <td>房屋坐落：</td>
                        <td style="padding-left: 50px;">
                            <input class="easyui-validatebox" type="text" id="houseaddr" data-options="required:true" style="width: 800px;" missingMessage="必填" placeholder="请输入房屋坐落" maxlength="40" /></td>
                    </tr>
                    <tr>
                        <td>房屋用途：</td>
                        <td style="padding-left: 50px;">
                            <select class="easyui-combobox" style="width: 800px;" id="select1"  data-options="editable:false">
                                <%=DictionaryBD() %>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td>建成年代：</td>
                        <td style="padding-left: 50px;">
                            <input class="easyui-validatebox" type="text" id="startyear" data-options="required:true" style="width: 800px;" missingMessage="必填" placeholder="请输入建成年代" maxlength="20" /></td>
                    </tr>
                    <tr>
                        <td>建成年代来源：</td>
                        <td style="padding-left: 50px;">
                            <select class="easyui-combobox" style="width: 800px;" id="select2"  data-options="editable:false">
                                <%=YersBD() %>
                            </select></td>
                    </tr>
                    <tr>
                        <td>报告类型：</td>
                        <td style="padding-left: 50px;">
                            <select class="easyui-combobox" style="width: 800px;" id="select3"  data-options="editable:false">
                                <%=BGTypeBD() %>
                            </select></td>
                    </tr>
                    <tr>
                        <td>评估受理：</td>
                        <td style="padding-left: 50px;">

                            <input class="mm" name="chk_deng" type="checkbox" value="审核评估登记表" />审核评估登记表 
                            <input class="mm" name="chk_deng" type="checkbox" value="身份证明" />身份证明 
                            <input class="mm" name="chk_deng" type="checkbox" value="房屋权属" />房屋权属 
                            <input class="mm" name="chk_deng" type="checkbox" value="网签合同" />网签合同 
                        </td>
                    </tr>
                    <tr>
                        <td>所属部门：</td>
                        <td style="padding-left: 50px;">
                            <select class="easyui-combobox" style="width: 800px;" id="select4"  data-options="editable:false">
                                <option>--请选择--</option>
                                <%=departmentBD() %>
                            </select></td>
                    </tr>
                    <tr>
                        <td>勘察员：</td>
                        <td style="padding-left: 50px;">
                            <select class="easyui-combobox" style="width: 800px;" id="select5"  data-options="editable:false">
                                <option>--请选择--</option>
                                <%=surveyDB(2) %>
                            </select></td>
                    </tr>
                    <tr>
                        <td>估价员：</td>
                        <td style="padding-left: 50px;">
                            <select class="easyui-combobox" style="width: 800px;" id="select6"  data-options="editable:false">
                                <option>--请选择--</option>
                                <%=surveyDB(3) %>
                            </select></td>
                    </tr>
                    <tr>
                        <td>评估通知单出具日期：</td>
                        <td style="padding-left: 50px;">
                            <input class="easyui-tex" type="text" id="riqi" data-options="required:true" style="width: 800px;" missingMessage="必填" placeholder="请输入评估通知单出具日期" maxlength="40" /></td>
                    </tr>
                </table>
            </div>
            <div style="text-align: center; padding: 5px">
                <a class="easyui-linkbutton" id="btn">登记</a>
            </div>
        </div>
    </div>
    <script>

        var ag = 0;
        //添加借款人
        function add() {
            ag++;
            if (ag > 5) {
                $.messager.alert("提示", "借款人最多添加六个");
            }
            else {
                $("#tbtb").append("<tr><td><span>借款人员姓名：</span><input type=\"text\" name=\"name\" /></td><td><span>身份证号：</span><input type=\"text\" name=\"idCard\" /></td><td><span>联系电话：</span><input type=\"text\" name=\"telNumber\" /></td><td><a href=\"#\" onclick=\"delperson(this)\">删除借款人</a></td></tr>");
            }
        }
        //删除借款人
        function delperson(obj) {
            $(obj).parent().parent().remove();
        }

        //登记
        $('#btn').bind('click', function () {
            var loan_Name = "";//获取借款人
            for (var i = 0; i < $(".a").length; i++) {
                loan_Name += $(".a").eq(i).val() + ",";
            }
            loan_Name = loan_Name.substring(0, loan_Name.length - 1);

            var loan_IdCard = "";//获取借款人身份证号
            for (var i = 0; i < $(".b").length; i++) {
                loan_IdCard += $(".b").eq(i).val() + ",";
            }
            loan_IdCard = loan_IdCard.substring(0, loan_IdCard.length - 1);

            var loan_TEL = "";//获取借款人联系方式
            for (var i = 0; i < $(".c").length; i++) {
                loan_TEL += $(".c").eq(i).val() + ",";
            }
            loan_TEL = loan_TEL.substring(0, loan_TEL.length - 1);

            var assessment = "";//获取评估受理
            for (var i = 0; i < $(".mm").length; i++) {
                if ($(".mm").eq(i).attr("checked") == "checked") {
                    assessment += $(".mm").eq(i).val() + ",";
                }
            }
            assessment = assessment.substring(0, assessment.length - 1);
            var loan_Contacts = $("#linkmen").val();//获取联系人
            var loan_ContactsTEL = $("#linknumber").val();//获取联系人电话
            var surplus_Years = $("#overyears").val();//获取年限
            var basic_Quota = $("#Quota").val();//获取额度
            var house_Located = $("#houseaddr").val();//获取房屋坐落
            var house_Purpose = $("#select1").combobox('getValue');//获取房屋用途
            var house_Time = $("#startyear").val();//获取年代
            var yers_Source = $("#select2").combobox('getValue');//获取房屋年代来源
            var presentation_Type = $("#select3").combobox('getValue');//获取报告类型

            var the_Department = $("#select4").combobox('getValue')//获取部门
            var survey = $("#select5").combobox('getValue')//获取勘察员
            var evaluation = $("#select6").combobox('getValue')//获取估价员
            var issue_Time = $("#riqi").val();

            $.ajax({
                type: "post",
                url: "LiXiangRegistered.aspx/AddBasicInfo",
                data: "{'loan_Name':'" + loan_Name + "','loan_IdCard':'" + loan_IdCard + "','loan_TEL':'" + loan_TEL + "','loan_Contacts':'" + loan_Contacts + "','loan_ContactsTEL':'" + loan_ContactsTEL + "','surplus_Years':'" + surplus_Years + "','basic_Quota':'" + basic_Quota + "','house_Located':'" + house_Located + "','house_Purpose':'" + house_Purpose + "','yers_Source':'" + yers_Source + "','house_Time':'" + house_Time + "','presentation_Type':'" + presentation_Type + "','the_Department':'" + the_Department + "','survey':'" + survey + "','evaluation':'" + evaluation + "','issue_Time':'" + issue_Time + "','assessment':'" + assessment + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                async: false,
                success: function (obj) {

                    if (obj) {
                        $.messager.alert('登记借款人信息', '登记成功', 'info', function () {
                            
                            parent.removeTab();
                            parent.addTab("项目立项列表", "/ProjectInitiation/LiXiangList.aspx", "icon-chart-organisation", true);
                            
                        });
                    }
                    else {
                        $.messager.alert('登记借款人信息', '登记失败');
                    }
                }
            })
        });


        // onChange
        $("#select4").combobox({
            onChange: function (newValue) {
                GJSelectBD(newValue);
                KCSelectBD(newValue);
            }
        });



        //估计员下拉框绑定
        function GJSelectBD(newValue) {
            $.ajax({
                type: "post", //要用post方式                 
                url: "LiXiangRegistered.aspx/KCSelectBD",//方法所在页面和方法名
                data: "{'newValue':'" + newValue + "','role':3}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    var json = eval("(" + data.d + ")");
                    $("#select6").combobox({
                        data: json,
                        valueField: 'users_Id',
                        textField: 'users_Name'
                    })

                }
            })
        }
        //勘察元下拉框绑定
        function KCSelectBD(newValue) {
            $.ajax({
                type: "post", //要用post方式                 
                url: "LiXiangRegistered.aspx/KCSelectBD",//方法所在页面和方法名
                data: "{'newValue':'" + newValue + "','role':2}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    var json = eval("(" + data.d + ")");
                    $("#select5").combobox({
                        data: json,
                        valueField: 'users_Id',
                        textField: 'users_Name'
                    })
                }

            })
        }


    </script>
</body>
</html>
